#ifndef SELF_DEFINE_FUNCTIONS_H_INCLUDED
#define SELF_DEFINE_FUNCTIONS_H_INCLUDED


#include "./CEC2013/cec2013.h"
#include <math.h>
#include <boost/random.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/cauchy_distribution.hpp>
#include <boost/random/normal_distribution.hpp>
#include <boost/random/uniform_real.hpp>
#include <vector>


using namespace std;

const int timesOfRun = 51;


const double epsilon_set[] = {1e-1,1e-2,1e-3,1e-4,1e-5};
const int epsilon_set_size = 5;

#define PI 3.1415926535898
#define yigexino 0.0000000001
//#define sigma 0.1
#define sigmamax 0.1
#define sigmamin 0.01

struct NewType
{
    double data;
    int id;
};


void adaptiveFcr1( int base,int selected_particle_indexbase, int population_size, int *ranking, NewType *tempsortfitness, double *results, double *cr, double *F ,double *tempresults,double *Fcr,double *Fcr1);

void Ranking_basedfitness_increase( int *ranking, NewType *tempsortfitness, double *input, int num);

void Ranking_basedfitness_decrease( int *ranking, NewType *tempsortfitness, double *input, int num);

void Ranking_baseddistance_increase( int **ranking_dis, NewType **tempsortdistance, double **input, int num);

void Ranking_Distance_sort( double sigma,int population_size, int dim,NewType **tempsortdistance,int **rank_result, double **temp_distance, double **W,double **P,double **q,double **population);

//void Ranking_Distance( int population_size, int dim,int **rank_result, double **temp_distance, double **W,double **P,double **q,double **population);

void PLS( int population_size, int dim,int &Fes,int MAX_FES,int *ranking,NewType *tempsortfitness,double *tempresults1,double *results, double *PLSsigma, double PLSxbetter_fitness,double *PLSP,double *PLSxbetter,double *PLSxnew_fitness,double **PLSxnew,double **population,double*LBound, double *UBound,CEC2013 *pFunc );

//void PLS2( int population_size, int dim,int &Fes,int MAX_FES,double *results, double *PLSsigma, double *PLSP,double **population,double*LBound, double *UBound,CEC2013 *pFunc );

void adaptiveFcr( int population_size, int *ranking, NewType *tempsortfitness, double *results, double *cr, double *F ,double *tempresults,double *Fcr);

void Select_Rand_Number(int base, int range, int *selected_numbers, int num, double **q,double *results);

void DE_Child1( double *parenti,double *child, double *parent1, double *parent2, double *parent3, int dim, double*LBound, double *UBound, double cr, double F );

bool Compare_NewType( NewType data1, NewType data2 );

bool Compare_NewType2( NewType data1, NewType data2 );

double Fitness ( double *particle, int &Fes, CEC2013 *pFunc );

void Popupation_Fitness( double **population, int population_size, int &Fes, double *result, CEC2013 *pFunc );

void DE_Child( double *child, double *parent1, double *parent2, double *parent3, int dim, double*LBound, double *UBound, double cr, double F );

double Distance( double *vector1, vector<double> vector2, int dim );

double Distance( double *vector1, double *vector2, int dim );

int Close_Particle( double *child, double **population, int population_size, int dim );

void Get_Seeds( double **population, double *population_results, int population_size, int dim, vector<double> &seed_fitness, double radius );

int How_Many_Global_Optima( vector<double> seed_fitness, double epsilon, CEC2013 *pFunc );

int Compute_Global_Optima_Found( double **population, double *population_results, int population_size, int dim, double epsilon, CEC2013 *pFunc );

#endif // SELF_DEFINE_FUNCTIONS_H_INCLUDED
